package org.carl.base.dingtalk.bot.model;


import cn.hutool.json.JSONUtil;
import lombok.Getter;
import lombok.Setter;
import org.carl.base.dingtalk.bot.enums.MsgTypeEnum;

/**
 * @author Carl
 */
@Getter
public class TextMsgModel extends MsgModel {
    private TextMsgModel() {
        msgtype = MsgTypeEnum.text;
    }

    /**
     * 创建一个text对象
     *
     * @param text
     * @return
     */
    public static TextMsgModel text(String text) {
        TextMsgModel textMsgModel = new TextMsgModel();
        Text t = new Text();
        t.setContent(text);
        textMsgModel.text = t;
        textMsgModel.at = new At();
        return textMsgModel;
    }

    /**
     * 创建一个test和at对象
     *
     * @param text
     * @param at
     * @return
     */
    public static TextMsgModel textAndAt(String text, At at) {
        TextMsgModel textMsgModel = text(text);
        textMsgModel.at = at;
        return textMsgModel;
    }

    /**
     * 被@的对象 需要传手机号
     */
    private At at;

    private Text text;


    @Getter
    @Setter
    public static class Text {
        private String content;
    }

    @Override
    public String toString() {
        return JSONUtil.toJsonStr(this);
    }
}
